package com.liuche.common;

import java.sql.SQLException;
import java.util.Iterator;

import org.apache.log4j.jdbc.JDBCAppender;
import org.apache.log4j.spi.LoggingEvent;

public class MyJDBCAppender extends JDBCAppender {
	@Override
	public void flushBuffer() {
		this.removes.ensureCapacity(this.buffer.size());
		Iterator i = this.buffer.iterator();
		if (i.hasNext())
		try {
			LoggingEvent logEvent = (LoggingEvent) i.next();
			String sql = getLogStatement(logEvent);
			execute(sql);
			this.removes.add(logEvent);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
